package com.myzhouye.biz.dto;/***
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 */

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

/**
 * @program: game01
 * @description: 基础仓库
 * @author: 那条蠢鱼
 * @create: 2025-09-30 10:04
 **/
@Data
@Schema(description = "基础仓库")
public class BaseWarehouse {
    @Schema(description = "仓库总容量")
    private Integer capacity;
    @Schema(description = "仓库个数")
    private Integer size;

    @Schema(description = "仓库货物")
    private Map<String,Integer> items;

    // 添加用户ID字段
    @Schema(description = "所属用户ID")
    private Long userId;

    @Schema(description = "剩余空间")
    public Integer getFreeSpace() {
        //如果没有仓库，返回-1
        if(size==0) {
            return -1;
        }
        return capacity - items.values().stream().mapToInt(Integer::intValue).sum();
    }
}
